import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import axios from "axios";
import "lib-flexible/flexible";
import animated from "animate.css";
import Vant from "vant";
import "vant/lib/index.css";
import VueLazyload from "vue-lazyload";

Vue.use(VueLazyload, {
	preLoad: 1.3,
	error: "./static/img/planb.jpg",
	loading: require("./static/img/loading.gif"),
	attempt: 1,
});

//路由拦截
router.beforeEach((to, from, next) => {
	document.title = to.meta.title;
	const state = JSON.parse(localStorage.getItem("state"));
	if (!state && to.path != "/adress" && from.path != "/adress") {
		next("/adress");
	}
	next();
});

Vue.use(animated);
Vue.use(Vant);

Vue.prototype.$axios = axios;
Vue.config.productionTip = false;

new Vue({
	router,
	store,
	render: (h) => h(App),
}).$mount("#app");
